<template>
  <div class="home-container">
    <van-nav-bar class="page-nav-bar" fixed>
      <van-button class="search-btn" slot="title" type="info" size="small" round
        icon="search" to="/layout/search">搜索</van-button>
    </van-nav-bar>
    <van-tabs class="channel-tabs" v-model="active" animated swipeable>
      <van-tab :title="obj.name" v-for="obj in list" :key="obj.id">
        <aa :channet='obj.id'></aa>
      </van-tab>
      <div slot="nav-right" class="placeholder">
      </div>
      <div slot="nav-right" @click="show=!show" class="hamburger-btn">
        <i class="toutiao toutiao-gengduo"></i>
      </div>
    </van-tabs>
    <!--频道编辑弹出层 -->
    <van-popup v-model="show" closeable position="bottom"
      :style="{ height: '100%' }" close-icon-position="top-left">
      <bb :list='list' :active='active' @Editactive='edactive'></bb>
    </van-popup>
  </div>
</template>
<script>
import bb from './components/ChannelEdi.vue'
import aa from '@/views/home/components'
import { getUserChannels } from '@/api/user.js'
export default {
  data () {
    return {
      active: 0,
      list: [],
      show: false
    }
  },
  async created () {
    const res = await getUserChannels()
    console.log(res)
    this.list = res.data.data.channels
    console.log(this.list[0].id)
  },
  components: {
    aa,
    bb
  },
  methods: {
    edactive (index) {
      this.active = index
    }
  }
}
</script>

<style scoped lang="less">
// .flex {
//   direction: flex;
//   justify-content: space-between;
// }
.home-container {
  /* home-container内部的 其他已开发样式 这里省略 */
  /deep/ .van-nav-bar__title {
    max-width: unset;
  }
  .search-btn {
    width: 555px;
    height: 64px;
    background-color: #5babfb;
    border: none;
    font-size: 28px;
    .van-icon {
      font-size: 32px;
    }
  }
  /* 添加tabs样式 */
  /deep/ .channel-tabs {
    .van-tabs__wrap {
      height: 82px;
      position: fixed;

      top: 92px;
      z-index: 1;
      right: 0;
      left: 0;
    }
    .van-tab {
      min-width: 200px;
      border-right: 1px solid #edeff3;
      font-size: 30px;
      color: #777777;
    }

    .van-tab--active {
      color: #333333;
    }

    .van-tabs__nav {
      padding-bottom: 0;
    }

    .van-tabs__line {
      bottom: 8px;
      width: 31px !important;
      height: 6px;
      background: #3296fa;
    }
  }
}
.placeholder {
  width: 66px;
  height: 82px;
}
.hamburger-btn {
  position: fixed;
  right: 0;
  display: flex;
  justify-content: center;
  align-items: center;
  width: 66px;
  height: 82px;
  background-color: #fff;
  opacity: 0.902;
  i.toutiao {
    font-size: 33px;
  }
  &:before {
    content: "";
    position: absolute;
    left: 0;
    width: 1px;
    height: 58px;
    background-image: url(~@/img/gradient-gray-line.png);
    background-size: contain;
  }

  .home-container {
    padding-bottom: 100px;
  }
}
</style>
